package com.itheima.work01;

import java.util.concurrent.ArrayBlockingQueue;
import java.util.concurrent.Executors;
import java.util.concurrent.ThreadPoolExecutor;
import java.util.concurrent.TimeUnit;

//2、自定义线程池，并提交任务
public class Work02 {
    public static void main(String[] args) {
        ThreadPoolExecutor tpe = new ThreadPoolExecutor(2,
                5,
                60,
                TimeUnit.SECONDS,
                new ArrayBlockingQueue<>(10),
                Executors.defaultThreadFactory(),
                new ThreadPoolExecutor.AbortPolicy()

                );
        for (int i =0;i<16;i++) {
            tpe.submit(()->{
                System.out.println(Thread.currentThread().getName()+"执行了");
            });
        }
    }
}
